package com.songjia.stream.producer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.annotation.InboundChannelAdapter;
import org.springframework.integration.annotation.Poller;
import org.springframework.integration.core.MessageSource;
import org.springframework.messaging.support.GenericMessage;

/**
 * 
 * 
 * @Description: 自定义消息生产者
 *
 * @author: songjia
 * @date: 2018年3月27日 上午11:02:28
 */
@EnableBinding(Source.class)
public class SinkSender {

	private static Logger logger = LoggerFactory.getLogger(SinkSender.class);

	@Value("${server.port}")
	private String port;

	@Bean
	@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedDelay = "5000"))
	public MessageSource<String> timerMessageSource() {
		logger.info("port: {}", port);
		return () -> new GenericMessage<>("{\"name\":\"didi\", \"age\":30}");
	}
}
